package com.hb.trans.mvp.presenter

import com.basiclib.base.BasePresenter
import com.basiclib.network.RxErrorHandler
import com.hb.trans.mvp.contract.MessageCenterContract
import com.hb.trans.mvp.model.MessageCenterModel
import javax.inject.Inject

class MessageCenterPresenter @Inject constructor(_mModel: MessageCenterModel, var errorHandler: RxErrorHandler) :
    BasePresenter<MessageCenterContract.View, MessageCenterContract.Model>(_mModel) {
//    fun getById() {
//        mModel.getById()
//            .subscribeOn(Schedulers.io())
//            .retryWhen(RetryWithDelay())
//            .observeOn(AndroidSchedulers.MessageCenterThread())
//            .compose(RxLifecycleUtils.bindToLifecycle(mRootView!!))
//            .subscribe(object : ErrorHandleSubscriber<Base<Update>>(errorHandler) {
//                override fun next(r: Base<Update>) {
//                    if (r.code == 1) {
//                        mRootView?.setGetById(r.data)
//                    } else {
//                        mRootView?.showShortToast(r.info ?: "")
//                    }
//                }
//            })
//    }

//    fun getLocationInfo(location: Location) {
//        mModel.getLocationInfo(location)
//            .subscribeOn(Schedulers.io())
//            .retryWhen(RetryWithDelay())
//            .observeOn(AndroidSchedulers.MessageCenterThread())
//            .compose(RxLifecycleUtils.bindToLifecycle(mRootView!!))
//            .subscribe(object : ErrorHandleSubscriber<Geocoder>(errorHandler) {
//                override fun next(r: Geocoder) {
//                    if (r.status == 0) {
//                        val addressComponent = r.result.addressComponent
//                        mRootView?.setCurrentLocationCity(
//                            addressComponent.province,
//                            addressComponent.city,
//                            addressComponent.district
//                        )
//                    } else {
//                        mRootView?.showShortToast("获取城市信息失败，请返回重试")
//                    }
//                }
//            })
//    }
}